package com.eastseeway.radioproject.engineer;

import androidx.recyclerview.widget.DiffUtil;

import java.util.List;

public class MyDiffCallback extends DiffUtil.Callback {
    private List<EngineerItemBean> oldList;
    private List<EngineerItemBean> newList;

    MyDiffCallback(List<EngineerItemBean> oldList, List<EngineerItemBean> newList) {
        this.oldList = oldList;
        this.newList = newList;
    }

    @Override
    public int getOldListSize() {
        return oldList.size();
    }

    @Override
    public int getNewListSize() {
        return newList.size();
    }

    @Override
    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
        // 比较两个items是否是同一个物理对象
        return oldList.get(oldItemPosition).getItemValue().equalsIgnoreCase(newList.get(newItemPosition).getItemValue());
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
        // 比较两个items的内容是否相同
        return oldList.get(oldItemPosition).equals(newList.get(newItemPosition));
    }
}
